import * as Vue from 'vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
import router from './router';
// import '@/assets/css/index_06CEAE.css';
import './styles/index_el.scss';
import './styles/index.scss';
import App from './App.vue';
import '@/assets/css/os-theme-minimal-light.css';
import 'overlayscrollbars/css/OverlayScrollbars.min.css';
// pinia代替vuex
import pinia from './store';
import '@/utils/request/interceptor.ts';
import 'vue-simple-uploader/dist/style.css';
import 'virtual:svg-icons-register';
import { parseProjectId, setLocalstorage } from '@/utils/localstorage.ts';
import { getNewClientConfig } from '@/api/app';

if (!window.Vue) window.Vue = Vue;

const render = async () => {
	const { data } = await getNewClientConfig(parseProjectId());
	if (data) {
		// 一些配置存在localStorage里，方便使用
		setLocalstorage('tenantId', String(data.tenantId));
		setLocalstorage('clientSecret', data.clientSecret);
		setLocalstorage('clientId', data.clientId);
	}
	const app = Vue.createApp(App);
	app.use(pinia);

	app.use(ElementPlus, {
		locale: zhCn
	});
	app.use(router);

	app.mount('#app');
};

render();
